﻿<navigation:Page 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:ia="http://schemas.microsoft.com/expression/2010/interactivity"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:tlk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           xmlns:gala="http://www.galasoft.ch/mvvmlight"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:my="clr-namespace:Candy" xmlns:Controls="clr-namespace:Candy.Controls" x:Class="Candy.ProjectPage"
           xmlns:vm="clr-namespace:Candy.ViewModel"
           mc:Ignorable="d"
           d:DesignWidth="1361" d:DesignHeight="713"
           Title="Project">
    <navigation:Page.Resources>
        <DataTemplate DataType="vm:GeneAnnotationEditViewModel">
            <Grid Margin="0,0,0,16" d:DesignWidth="475" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid x:Name="Footer" Background="{StaticResource ControlBackgroundDark}" Grid.Row="1" Margin="0,4,0,0" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>

                    </Grid.ColumnDefinitions>
                    <Button ToolTipService.ToolTip="Edit" HorizontalAlignment="Center" Margin="0" x:Name="button8" VerticalAlignment="Center" Command="{Binding Edit}" Style="{StaticResource IconButton}" Grid.Column="0" >
                        <Image Stretch="None" Source="Images/Icons/Edit.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Button>
                    <Button ToolTipService.ToolTip="Delete" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" Command="{Binding Delete}" Style="{StaticResource IconButton}" Grid.Column="1" >
                        <Image Stretch="None" Source="Images/Icons/Delete.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Button>
                    <Button ToolTipService.ToolTip="CANCEL" HorizontalAlignment="Left" Margin="8,0,0,0" x:Name="button11" VerticalAlignment="Top" Command="{Binding CancelEdit}" Style="{StaticResource IconButton}" Grid.Column="2" >
                        <Image Stretch="None" Source="Images/Icons/Cancel.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Button>
                    <Button ToolTipService.ToolTip="Save" HorizontalAlignment="Left" x:Name="button12" VerticalAlignment="Top" Command="{Binding Save}" Style="{StaticResource IconButton}" Margin="4,0,0,0" Grid.Column="3">
                        <Image Stretch="None" Source="Images/Icons/Save.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Button>

                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Opacity="0.6" Grid.Column="6">
                        <!--<Image HorizontalAlignment="Left" Height="20" Margin="0,0,4,0" VerticalAlignment="Top" Width="20" Source="{Binding Entity.CreatorProfilePic}" Stretch="UniformToFill"/>
                    <TextBlock Text="{Binding Entity.Creator, StringFormat=Created by \{0\}, FallbackValue=Created by Jan}" Margin="0,0,4,0" />
                    <TextBlock Text="{Binding Entity.CreateDate, StringFormat=at \{0\}, FallbackValue=at 01/04/2013 14:00}" Margin="0,0,8,0" />-->

                        <TextBlock Text="{Binding Entity.ModifiedDate, StringFormat=Last edit at \{0\}, TargetNullValue=at 01/04/2013 14:00}" />
                        <TextBlock Text="{Binding Entity.Modifier, StringFormat=by \{0\}, TargetNullValue=Modified by Candy}" Margin="4,0,4,0" />
                        <Image HorizontalAlignment="Left" Height="20" Margin="0,0,4,0" VerticalAlignment="Top" Width="20" Source="{Binding Entity.ModifierProfilePic, TargetNullValue=Images/AppIcons/Candy128.png}" Stretch="UniformToFill"/>
                    </StackPanel>

                </Grid>
                <Grid x:Name="Content" Grid.Row="0" >
                    <TextBox Text="{Binding Entity.Value, Mode=TwoWay}" IsReadOnly="{Binding IsEditing, Converter={StaticResource NegateConverter}}"   AcceptsReturn="True" TextWrapping="Wrap"  />
                </Grid>
            </Grid>
        </DataTemplate>
        <DataTemplate DataType="vm:GeneReferenceEditViewModel">
            <Grid Margin="0,0,0,16" d:DesignWidth="475" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid x:Name="Footer" Background="{StaticResource ControlBackgroundDark}" Grid.Row="1" Margin="0,4,0,0" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>

                    </Grid.ColumnDefinitions>
                    <Button ToolTipService.ToolTip="Edit" HorizontalAlignment="Center" Margin="0" x:Name="button8" VerticalAlignment="Center" Command="{Binding Edit}" Style="{StaticResource IconButton}" Grid.Column="0" >
                        <Image Stretch="None" Source="Images/Icons/Edit.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Button>
                    <Button ToolTipService.ToolTip="Delete" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" Command="{Binding Delete}" Style="{StaticResource IconButton}" Grid.Column="1" >
                        <Image Stretch="None" Source="Images/Icons/Delete.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Button>
                    <Button ToolTipService.ToolTip="CANCEL" HorizontalAlignment="Left" Margin="8,0,0,0" x:Name="button11" VerticalAlignment="Top" Command="{Binding CancelEdit}" Style="{StaticResource IconButton}" Grid.Column="2" >
                        <Image Stretch="None" Source="Images/Icons/Cancel.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Button>
                    <Button ToolTipService.ToolTip="Save" HorizontalAlignment="Left" x:Name="button12" VerticalAlignment="Top" Command="{Binding Save}" Style="{StaticResource IconButton}" Margin="4,0,0,0" Grid.Column="3">
                        <Image Stretch="None" Source="Images/Icons/Save.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Button>

                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Opacity="0.6" Grid.Column="6">
                        <TextBlock Text="{Binding Entity.ModifiedDate, StringFormat=Last edit at \{0\}, FallbackValue=at 01/04/2013 14:00}" />
                        <TextBlock Text="{Binding Entity.Modifier, StringFormat=by \{0\}, FallbackValue=Modified by Jan}" Margin="4,0,4,0" />
                        <Image HorizontalAlignment="Left" Height="20" Margin="0,0,4,0" VerticalAlignment="Top" Width="20" Source="{Binding Entity.ModifierProfilePic}" Stretch="UniformToFill"/>
                    </StackPanel>

                </Grid>
                <Grid x:Name="Content" Grid.Row="0" >
                    <HyperlinkButton    TargetName="_blank" NavigateUri="{Binding Link}"  Visibility="{Binding IsEditing, ConverterParameter=negate, Converter={StaticResource VisibilityConverter}}">
                        <TextBlock Text="{Binding Title, FallbackValue=NCBI Entry}" TextWrapping="Wrap"/>
                    </HyperlinkButton>
                    <Grid x:Name="Editor" Visibility="{Binding IsEditing, Converter={StaticResource VisibilityConverter}}">
                        <Grid.ColumnDefinitions>

                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="Title" Grid.Row="0" />
                        <TextBox Text="{Binding Title, Mode=TwoWay}" Grid.Row="1" />
                        <TextBlock Text="Link" Grid.Row="2" />
                        <TextBox Text="{Binding Link, Mode=TwoWay, ValidatesOnExceptions=True}"  Grid.Row="3"/>
                    </Grid>
                </Grid>


            </Grid>
        </DataTemplate>
    </navigation:Page.Resources>
    <ScrollViewer Background="{x:Null}" VerticalScrollBarVisibility="Disabled">
        <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource Locator}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid x:Name="FamilieGeneGrid" Grid.Row="1" ShowGridLines="False">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="250"/>
                    <ColumnDefinition Width="400"/>
                    <ColumnDefinition Width="700"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid x:Name="FamilyGrid" Height="Auto"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="Auto" DataContext="{Binding Families, Mode=OneWay}" >
                 
                    <sdk:TreeView SelectedItemChanged="FamilyTree_SelectedItemChanged"   x:Name="FamilyTree" ItemsSource="{Binding Families}" Grid.ColumnSpan="3"   Margin="8,0,0,0"  Height="Auto" Width="Auto" VerticalAlignment="Stretch"  HorizontalAlignment="Stretch" >
                        <tlk:ContextMenuService.ContextMenu>
                            <tlk:ContextMenu  >
                                <tlk:MenuItem Header="New Family" Command="{Binding CreateFamily, Mode=OneWay}" />
                                <tlk:Separator/>
                               
                                <tlk:MenuItem Header="Expand All" Click="ExpandAll"/>
                                <tlk:MenuItem Header="Collapse All" Click="CollapseAll"/>
                            </tlk:ContextMenu>
                        </tlk:ContextMenuService.ContextMenu>
                        <sdk:TreeView.ItemTemplate >
                            <sdk:HierarchicalDataTemplate  ItemsSource="{Binding SubFamilies}"  >
                                <Grid Background="Transparent" MouseLeftButtonDown="OnFamiliyDoubleClick" >
                                    <tlk:ContextMenuService.ContextMenu>
                                        <tlk:ContextMenu >
                                            <tlk:MenuItem Header="New" CommandParameter="{Binding Mode=OneWay}" Command="{Binding Families.CreateFamily, Mode=OneWay, Source={StaticResource Locator}}" />
                                            <tlk:MenuItem Header="Edit" CommandParameter="{Binding Mode=OneWay}" Command="{Binding Families.EditFamily, Mode=OneWay, Source={StaticResource Locator}}" />
                                            <tlk:MenuItem Header="Delete" CommandParameter="{Binding Mode=OneWay}" Command="{Binding Families.DeleteFamily, Mode=OneWay, Source={StaticResource Locator}}" />
                                            <tlk:Separator/>
                                            <tlk:MenuItem Header="Move To"  Command="{Binding Families.Move, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="{Binding Mode=OneWay}" />
                                            <tlk:MenuItem Header="Copy as FastA" CommandParameter="{Binding Mode=OneWay}" Command="{Binding Families.CopyAsFasta, Mode=OneWay, Source={StaticResource Locator}}" />
                                            <tlk:Separator HorizontalAlignment="Stretch"/>
                                            <tlk:MenuItem Header="Blast" CommandParameter="{Binding Entity, Converter={StaticResource JobDefinitionConverter}, Mode=OneWay}" Command="{Binding JobManager.CreateJob, Mode=OneWay, Source={StaticResource Locator}}" />
                                        </tlk:ContextMenu>
                                    </tlk:ContextMenuService.ContextMenu>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" MinWidth="0"/>
                                        <ColumnDefinition Width="Auto" MinWidth="0"/>
                                        <ColumnDefinition Width="Auto" MinWidth="0"/>
                                        <ColumnDefinition Width="Auto" MinWidth="0"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="{Binding Entity.Type, Converter={StaticResource FamilyTypeToSymbolConverter}}" FontSize="12" FontWeight="Bold" Margin="0,0,4,0" VerticalAlignment="Center" Foreground="{Binding Entity.Type, Converter={StaticResource FamilyTypeToColorConverter}}"  />
                                    <TextBlock  Text="{Binding Entity.Name}" Grid.Column="2" VerticalAlignment="Center" />
                                    <TextBlock Text="{Binding CountString}" Grid.Column="3" VerticalAlignment="Center" Visibility="{Binding EditMode, ConverterParameter=negate, Converter={StaticResource VisibilityConverter}}"/>
                                </Grid>
                            </sdk:HierarchicalDataTemplate>
                        </sdk:TreeView.ItemTemplate>
                    </sdk:TreeView>
          
                </Grid>
                <!--</tlk:Expander>-->
                <sdk:GridSplitter x:Name="FamiliySplitter" Grid.Column="1" HorizontalAlignment="Left" Style="{StaticResource DefaultGridSplitter}" Width="6" ShowsPreview="True" />

                <sdk:TabControl Grid.Column="1"  Margin="7,0,0,0" HorizontalAlignment="Stretch">
                    <sdk:TabItem x:Name="genesTabItem" Header="List" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"  VerticalAlignment="Center" DataContext="{Binding Genes, Mode=OneWay}">
                        <Grid x:Name="GeneListGrid" Margin="0" >
                            <Grid.RowDefinitions>

                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <sdk:DataGrid x:Name="GeneDataGrid" AutoGenerateColumns="False"   ItemsSource="{Binding Genes}" Margin="0" Style="{StaticResource DefaultDataGrid}" ColumnHeaderStyle="{StaticResource DefaultDataGridColumnHeader}" RowStyle="{StaticResource DefaultDataGridRow}" CellStyle="{StaticResource DefaultDataGridCell}"  >
                                <ia:Interaction.Triggers>
                                    <ia:EventTrigger EventName="SelectionChanged">
                                        <gala:EventToCommand Command="{Binding SelectGenes}" PassEventArgsToCommand="True"/>
                                    </ia:EventTrigger>
                                </ia:Interaction.Triggers>
                                <tlk:ContextMenuService.ContextMenu>
                                    <tlk:ContextMenu >
                                        <tlk:MenuItem Header="New" Command="{Binding CreateGene, Mode=OneWay}"  />
                                        <tlk:MenuItem Header="Edit" Command="{Binding EditGene, Mode=OneWay}"  />
                                        <tlk:MenuItem Header="Delete" Command="{Binding DeleteGenes, Mode=OneWay}"/>
                                        <tlk:Separator HorizontalAlignment="Stretch"/>
                                        <tlk:MenuItem Header="Move" Command="{Binding MoveSelectedGenes, Mode=OneWay}"/>
                                        <tlk:MenuItem Header="Copy As FastA" Command="{Binding CopyAsFasta, Mode=OneWay}"/>
                                        <tlk:Separator HorizontalAlignment="Stretch"/>
                                        <tlk:MenuItem Header="Blast" CommandParameter="{Binding SelectedGenes, Converter={StaticResource GeneListConverter}, Mode=OneWay}" Command="{Binding JobManager.BlastSecondaryBaits, Mode=OneWay, Source={StaticResource Locator}}" />
                                    </tlk:ContextMenu>
                                </tlk:ContextMenuService.ContextMenu>
                                <sdk:DataGrid.Columns>
                                    <sdk:DataGridTemplateColumn Header=" ">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate >
                                                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Entity, Converter={StaticResource Gene2LabelConverter}}" Foreground="{Binding Entity, Converter={StaticResource Gene2ColorConverter}}"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                    <sdk:DataGridTextColumn  Header="Identifier" Binding="{Binding Entity.GeneIdentifier}" IsReadOnly="True"/>
                                    <sdk:DataGridTextColumn Header="Name" Binding="{Binding Entity.Name}" IsReadOnly="True"/>
                                    <sdk:DataGridTextColumn Header="Species" Binding="{Binding Entity.Genotype.Name}" IsReadOnly="True"/>

                                    <sdk:DataGridTextColumn Header="Family" Binding="{Binding Entity.Family.Name}" IsReadOnly="True"/>
                                    <sdk:DataGridTextColumn Header="SR" Binding="{Binding Entity.ScientificRelevance}" IsReadOnly="True"/>
                                </sdk:DataGrid.Columns>
                            </sdk:DataGrid>
                        </Grid>
                    </sdk:TabItem>
                    <sdk:TabItem Header="Phylogeny"  Visibility="Visible" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"   VerticalAlignment="Center" DataContext="{Binding Phylogenies, Mode=OneWay}" >
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto" MinHeight="0"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <StackPanel Margin="0,0,8,0" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Height="20" Width="66">
                            	<Button  HorizontalAlignment="Right" VerticalAlignment="Center"  Style="{StaticResource IconButton}" Command="{Binding CreatePhylogeny, Mode=OneWay}" Margin="0,0,8,0">
                            		<StackPanel Orientation="Horizontal">

                            			<Image Stretch="None" Source="Images/Icons/Add.png" />
                            		</StackPanel>
                            	</Button>
                            	<Button HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" Style="{StaticResource IconButton}" Height="18" Width="18" Command="{Binding EditPhylogeny, Mode=OneWay}" CommandParameter="{Binding SelectedPhylogeny}">
                            		<Image Stretch="None" Source="Images/Icons/Edit.png"/>
                            	</Button>
                            	<Button HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource IconButton}" Height="20" Width="20" Command="{Binding DeletePhylogeny, Mode=OneWay}" CommandParameter="{Binding SelectedPhylogeny}">
                            		<Image Stretch="None" Source="Images/Icons/Delete.png"/>
                            	</Button>

                            </StackPanel>
                            <ComboBox ItemsSource="{Binding Phylogenies}"  Foreground="Black" Grid.Row="1"  ItemContainerStyle="{StaticResource DefaultListBoxItem}" Height="76" VerticalAlignment="Top" SelectedItem="{Binding SelectedPhylogeny, Mode=TwoWay}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                    	<Grid d:DesignWidth="285" d:DesignHeight="76">
                                    		<Grid.RowDefinitions>
                                    			<RowDefinition Height="Auto"/>
                                    			<RowDefinition Height="Auto"/>
                                    			<RowDefinition Height="Auto"/>
                                    		</Grid.RowDefinitions>
                                    		<Grid.ColumnDefinitions>
                                    			<ColumnDefinition/>
                                    			<ColumnDefinition Width="Auto"/>
                                    			<ColumnDefinition Width="Auto"/>
                                    		</Grid.ColumnDefinitions>
                                    		<TextBlock Margin="4,4,0,4" Text="{Binding Entity.Name, FallbackValue=PhylogenyA}" VerticalAlignment="Center" Style="{StaticResource DefaultLabel}" TextTrimming="WordEllipsis" FontSize="{StaticResource ButtonFontSize}"/>

                                    		<TextBlock Margin="4,2,0,2" Grid.Row="1" Text="{Binding Entity.Description, FallbackValue=Hello Description here I come}" MaxHeight="70" Grid.ColumnSpan="3" Style="{StaticResource DefaultLabel}" TextTrimming="WordEllipsis" FontStyle="Italic" Opacity="0.8" Height="18"/>
                                    	     <Rectangle Grid.ColumnSpan="3" Margin="0,4,0,0" Grid.Row="2" Fill="{StaticResource ControlBackgroundDark}" />
											<StackPanel Grid.ColumnSpan="3" Margin="0,4,0,0" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Opacity="0.6">
                                    			<TextBlock HorizontalAlignment="Right" Margin="0,0,4,0" TextWrapping="Wrap" Text="{Binding Entity.CreateDate, FallbackValue=Created at 01/01/1975 12:00, StringFormat=Created at \{0:g\}, TargetNullValue=N/A}" Style="{StaticResource DefaultLabel}" VerticalAlignment="Center"/>
                                    			<TextBlock HorizontalAlignment="Right" Margin="0,0,4,0" TextWrapping="Wrap" Text="{Binding Entity.CreatedBy, FallbackValue=by Candy, StringFormat=by \{0\}, TargetNullValue=N/A}" Style="{StaticResource DefaultLabel}" VerticalAlignment="Center"/>
                                    			<Image Height="22" Margin="0" Width="22" HorizontalAlignment="Right" Source="{Binding Entity.CreatorProfilePic, FallbackValue=Images/AppIcons/Candy128.png}" />
                                    	  </StackPanel>

                                    	</Grid>
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                            <Controls:DendoCtrl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="2" Width="Auto" Height="Auto" Newick="{Binding SelectedPhylogeny.Entity.Tree}"/>
                        </Grid>
                    </sdk:TabItem>
                </sdk:TabControl>
                <sdk:GridSplitter x:Name="GeneSplitter" Grid.Column="2" HorizontalAlignment="Left" Style="{StaticResource DefaultGridSplitter}" Width="6" ShowsPreview="True" />
                <Border BorderThickness="0" Grid.Column="2" Margin="8,0,0,0" DataContext="{Binding Genes.SelectedGene}">
                    <Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto" MinHeight="26"/>
                            <RowDefinition Height="Auto" MinHeight="42" MaxHeight="200"/>
                            <RowDefinition Height="Auto" MinHeight="0"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <TextBlock HorizontalAlignment="Left" Grid.Row="2" TextWrapping="Wrap" Text="Sequence" VerticalAlignment="Center" Grid.ColumnSpan="2" Margin="8,4,0,4" FontSize="18" />
                        <TextBox HorizontalAlignment="Left" Margin="8,0,0,0" TextWrapping="Wrap" Text="{Binding Entity.GeneIdentifier, Mode=TwoWay, TargetNullValue=---, FallbackValue=---}" VerticalAlignment="Center" IsReadOnly="True" FontSize="{StaticResource HeaderFontSize}" Grid.RowSpan="1"/>
                        <TextBox HorizontalAlignment="Left" Margin="8,0,0,0" TextWrapping="Wrap" Text="{Binding Entity.Name, Mode=TwoWay, StringFormat=(\{0\}), TargetNullValue=---, FallbackValue=---}" VerticalAlignment="Center" IsReadOnly="True" FontSize="{StaticResource HeaderFontSize}" Grid.Column="1"  Grid.RowSpan="1"/>
                        <Controls:SequenceControl MaxHeight="200" Grid.Row="3" Grid.ColumnSpan="2" Sequence="{Binding Entity.ProteinSequence, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="8,0,0,4"/>
                        <TextBlock HorizontalAlignment="Left" Grid.Row="4" TextWrapping="Wrap" Text="Annotations" VerticalAlignment="Center" Margin="8,4,0,8" Grid.ColumnSpan="2" FontSize="18"/>
                        <StackPanel Margin="0" Orientation="Horizontal"  Grid.Row="1"  Grid.ColumnSpan="2">
                            <TextBlock Text="{Binding Entity.Family.Name, StringFormat=in family\/group \{0\}}" Margin="8,0,0,0" />
                            <TextBlock Text="{Binding Entity.Genotype.FullName, StringFormat=of species \{0\}, FallbackValue=of species N/A ,TargetNullValue=of species N/A }"/>
                            <TextBlock Text="{Binding Entity.Database.Name, StringFormat=from database \{0\}, FallbackValue=from database N/A ,TargetNullValue=from database N/A }" Margin="4,0,0,0" />
                        </StackPanel>
                        <ScrollViewer Grid.Row="5" Grid.ColumnSpan="2" Margin="8,0,1,8" HorizontalScrollBarVisibility="Disabled" >
                            <ItemsControl ItemsSource="{Binding AnnotationGroups}"  >
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Margin="0,0,0,8">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="*" />

                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition/>
                                                <RowDefinition/>

                                            </Grid.RowDefinitions>
                                            <Image Source="{Binding Type, Converter={StaticResource AnnotationType2IconConverter}}" Stretch="UniformToFill"  Margin="0,0,8,0" />
                                            <TextBlock Text="{Binding Title}" FontSize="14" Grid.Column="1" VerticalAlignment="Center"/>
                                            <Button ToolTipService.ToolTip="Add" Style="{StaticResource IconButton}" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0,0,0" Command="{Binding AddAnnotation, Mode=OneWay}" >
                                                <Image Source="Images/Icons/Add.png" Stretch="None"  />
                                            </Button>
                                            <ItemsControl Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" ItemsSource="{Binding Annotations}">

                                            </ItemsControl>
                                            <TextBlock Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"  Text="{Binding Type, StringFormat=No \{0\}}" HorizontalAlignment="Center" VerticalAlignment="Center" FontStyle="Italic" Opacity="0.4" Visibility="{Binding Annotations, ConverterParameter=negate, Converter={StaticResource ListNullOrEmptyVisibiltyConverter}}"/>

                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>
                    </Grid>
                </Border>
                <!--<sdk:GridSplitter Grid.Column="3" HorizontalAlignment="Left" Margin="0" Width="7"/>-->
            </Grid>
        </Grid>
    </ScrollViewer>
</navigation:Page>
